from django.db import models


class UserInfo(models.Model):
    """ 用户表 """
    username = models.CharField(verbose_name="用户名", max_length=32)
    password = models.CharField(verbose_name="密码", max_length=64)
    phone = models.CharField(verbose_name="手机号", max_length=11, db_index=True)
    token = models.CharField(verbose_name="token", max_length=64, null=True, blank=True, db_index=True)
    status_choice = ((1, "激活"), (2, "禁用"))
    status = models.IntegerField(verbose_name="状态", choices=status_choice, default=1)
    created_at = models.DateTimeField(verbose_name="创建时间", auto_now_add=True)

    class Meta:
        indexes = [models.Index(fields=['username', 'password'], name='idx_name_pwd')]


class HuaWeiCloud(models.Model):
    """ 云服务基础信息 """
    cloud_name = models.CharField(verbose_name="云运营商", max_length=64)
    cloud_user = models.CharField(verbose_name="云账号", max_length=64)
    cloud_ak = models.CharField(verbose_name="AK", max_length=128)
    cloud_sk = models.CharField(verbose_name="SK", max_length=128)
    cloud_zone = models.CharField(verbose_name="区域", max_length=64, default=0)


class CloudSecurityGroups(models.Model):
    cloud_env = models.CharField(verbose_name="系统环境", max_length=12)
    description = models.CharField(verbose_name="描述信息", max_length=64)
    remote_ip_prefix = models.CharField(verbose_name="IP地址", max_length=32)
